package com.qc.ayouth.shop.core.beans.bo;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public class ServiceResultBO implements Serializable {
    // 状态码   -1-失败    0-成功
    private Integer code;

    // 提示信息
    private String msg;

    // 返回的数据
    private Map<String, Object> data = new HashMap<String, Object>();

    public ServiceResultBO() { }

    public ServiceResultBO(Integer code, String message) {
        this.code = code;
        this.msg = message;
    }

    public ServiceResultBO(Integer code, String message, Map<String, Object> data) {
        this.code = code;
        this.msg = message;
        this.data = data;
    }

    public ServiceResultBO add(String key, Object value){
        this.getData().put(key, value);
        return this;
    }

    public void success() {
        this.code = 0;
    }

    public void fail(String msg) {
        this.code = -1;
        this.msg = msg;
    }
}
